package net163

import (
	"distributed/message"
	"regexp"
)

// <li>[^<]*<a[^h]*href="([^"]*)">([^<]*)</a>[^<]*</li>
var (
	headRegex = regexp.MustCompile(`<li>[^<]*<a[^h]*href="([^"]*)">([^<]*)</a>[^<]*</li>`)
)

func HomeParser(input string) *message.ReptileResp {
	result := headRegex.FindAllStringSubmatch(input, -1)
	resultBrief := make([]message.BriefInformation, len(result))
	for i, v := range result {
		resultBrief[i] = message.BriefInformation{
			URL:   v[1],
			Title: v[2],
		}
	}
	return &message.ReptileResp{ParserResult: &resultBrief}
}
